package com.yummy.security;

import java.util.List;

import org.springframework.util.AntPathMatcher;

public class AntPathPermissionMatcher implements PermissionMatcher{

	private AntPathMatcher matcher = new AntPathMatcher();

	@Override
	public boolean match(Permission pattern, String access) {
		if(pattern == null || access == null) {
			return false;
		}
		return matcher.match(access, access);
	}

	@Override
	public boolean match(List<Permission> permissions, String access) {
		if(permissions == null) {
			return false;
		}
		for(Permission p : permissions) {
			if(match(p,access)) {
				return true;
			}
		}
		return false;
	}

}
